package com.kaishengit.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.kaishengit.entity.Tour;
import com.kaishengit.util.DBHelp;
import com.kaishengit.util.RowMapper;

public class TourDao {
	private DBHelp<Tour> db = new DBHelp<Tour>();
	public Tour findByName(String name){
		String sql = "SELECT id,tourname FROM t_tour WHERE tourname=?";
		Tour t = db.executeForObject(sql, new TourRowMapper(), name);
		return t;
	}
	public void insertSale(String name){
		String sql = "INSERT INTO t_tour (tourname) VALUE(?)";
		db.executeUpdate(sql, name);
	}
	public class TourRowMapper implements RowMapper<Tour>{

		public Tour mapperRow(ResultSet rs) throws SQLException {
			Tour t = new Tour();
			t.setId(rs.getInt("id"));
			t.setTourname(rs.getString("tourname"));
			
			return t;
		}
		
	}
}
